From: Adam Trionfo ballyalley@hotmail.com [ballyalley]
Sent: Monday, February 25, 2019 3:31 PM
To: ballyalley@yahoogroups.com
Subject: Gate Escape's Machine Code
 

I decided to look into the machine language CALLs that are made from The Gate Escape.

The program uses CALL R throughout the code. R is set to 20200 when the program is loaded. 20200 is hex $4EE8. I used Ballybin 2 to get a look at the screen RAM. I ran the Gate Escape WAV through BallyBin 2 to create a BML file, like this:

ballybin -l3 -v2 -f2 -i1 -s -bCONVERTED.BML CONVERT.WAV

The options here presume that the WAV is pure data (not BASIC). This is how you get the proper hex dump.

With some fiddling with various programs (MS Word, the HxD hex editor, and the the DZ80 disassembler) I came up with the the hex digits stored in Gate Escape's screen memory. It that looks like this (see attached file for more details; not the filename):

Data from 4EE2-4f85:

42 0d ff ff 30 ff d5 ff 35 7b 22 28 f2 4e d1 c9
70 f8 4e 80 00 30 80 09 0f 02 09 ff 4e 00 00 00
00 03 80 05 40 0e e0 14 50 13 90 06 c0 0c 60 07
f0 08 08 0b 68 0b 68 08 88 05 50 12 a4 1a 2c 11
c4 03 e0 1f fc 05 50 04 90 0e 38 0f 78 0b e8 09
48 03 60 0e 70 13 c8 02 40 01 80 07 e0 09 90 11
88 02 40 0c 30 02 20 07 f0 04 90 05 d0 0f 78 1b
ec 09 c8 01 40 07 70 00 00 00 00 00 00 02 80 01
00 02 80 00 00 00 00 00 00 00 00 01 00 05 40 02
80 0d 60 02 80 05 40 01 00 00 00 00 00 8a 17 00
9a 09 28 00

This is probably a mix of code, graphics and "garbage." I've disassembled some of it by hand and with DZ80 and came up with this for a start:

4ee8 D5 PUSH DE
4ee9 FF35 SYSSUK STRDIS ; UPI STRing DISplay
4eeb 7B DB $7B ; ... X = 123
4eec 22 DB $22 ; ... Y = 34
4eed 28 DB $28 ; ... Options = 40
4eee F24E DW $4EF2 ; ... String Address = 20210
4ef0 ;
4ef0 D1 POP DE
4ef1 C9 RET

; STRDIS Interpretation of Codes

4ef2 70 IX ; Load IX with Alternate Font Descriptor Address
4ef3 F8 ; 4EF8 - Alternate Font
4ef4 4E

4ef5 80 ; User Supplied alternate font
4ef6 00 ; Exit

That's all I've disassembled so far, but I find it interesting. I always thought that the BASIC programs used the onboard DISCHR (Display Character on-board subroutine). I'm surprised to see that it's use the String Display routine with an alternate font set. Pretty neat! This makes sense, but I've not seen it before now. Or, I can't recall see in other BASIC programs.

I've attached a binary file where the above code begins to as far as BallyBin can decode it.

Can anyone else follow along with what I'm talking about here...? Who's listening...?

Adam
